// page/member/coupons.js
Page({
	data: {
		hasList: false,
		couponsList: [],
		lx: ''
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		var lx = options.lx;
		var that = this
		var uid = wx.getStorageSync('uid');
		utils.GET({
			url: 'Member/coupons',
			params: { uid: uid, lx: lx},
			success: function (res) {
				that.setData({
					couponsList: res.data.d,
					hasList: res.data.d ? true : false,
					lx: lx,
				})
			},
		})

	},
	sy: function (e) {
		var i = e.currentTarget.dataset.id;
		var thit = this;
		var data = thit.data.couponsList;
		var lx = thit.data.lx;
		// console.log(data);
		if (lx == 'ck') {
		} else {
			// console.log(2)
			var pages = getCurrentPages();
			var currPage = pages[pages.length - 1];   //当前页面
			var prevPage = pages[pages.length - 2];  //上一个页面

			//直接调用上一个页面的setData()方法，把数据存到上一个页面中去
			prevPage.setData({
				coupons_id: data[i]['id'],
				coupons_price: data[i]['limit'],
			})
			wx.navigateBack();
		}
	}
	,

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},
})